package ro.pub.cs.stadium.document.logic;
import java.util.Map;

import ro.pub.cs.stadium.document.AbstractDocument;
import ro.pub.cs.stadium.document.ITransition;

public class Document extends AbstractDocument {

	private VariableList vars;
	
	public void addState(State S) {
		getStates().put(S.getName(), S);
		vars.merge(S.getVariables());
	}

	public void addTransition(Transition T) {
		getTransitions().put(T.getName(), T);
		vars.merge(T.getCondition().getVariables());
	}
	
	public void removeState(State S) {
		Map<String,ITransition> ins = S.getInTransitions();
		Map<String,ITransition> outs = S.getOutTransitions();
		for (ITransition  T: ins.values()) removeTransition((Transition)T);
		for (ITransition  T: outs.values()) removeTransition((Transition)T);
		getStates().remove(S.getName());
		
	}
	
	public void removeTransition(Transition T) {
		getTransitions().remove(T.getName());
	}

	public VariableList getVariableList() {
		return vars;
	}
	
	public void removeVariable(Variable V) {
		vars.remove(V);
	}
}
